package indi.gao;


import java.util.HashMap;
import java.util.HashSet;
import java.util.TreeMap;

/**
 * <p>Description:</p>
 * <p>Copyright: Copyright (c)2020$</p>
 * <p>Company: Tope</p>
 * <P>Created Date :2020$-04$-01$</P>
 * <P>@version 1.0</P>
 */
public class HashMapTest {
    public static void main(String[] args) {
        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
        map map = new map(1);
        map map1 = new map(2);
        // put 返回值
        /**
         * the previous value associated with <tt>key</tt>, or null
         * if there was no mapping for key.
         * null return can also indicate that the map
         *  previously associated null with key
         */
        Object put1 = objectObjectHashMap.put("1", map);
        // 插入相同的key 覆盖原来的值
        Object put = objectObjectHashMap.put("1", map1);
        boolean b = objectObjectHashMap.containsKey("1");
        // 通过指针修改值
        Object o = objectObjectHashMap.get("1");
        ((map) o).anInt = 100;
        TreeMap<String, map> stringmapTreeMap = new TreeMap<>();
        indi.gao.map map2 = new map(100);
        indi.gao.map map3 = new map(50);
        stringmapTreeMap.put("2", map2);
        stringmapTreeMap.put("3", map3);
        System.out.println(stringmapTreeMap.toString());
        System.out.println();

    }

}

class map implements Comparable {
    map(int anInt) {
        this.anInt = anInt;
    }

    int anInt;

    @Override
    public int compareTo(Object o) {
        return ((map) o).anInt - this.anInt;
    }
}
